#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/8 17:06
# @Author  : jeff wu
# @FileName: scheduler_config
from apscheduler.schedulers.background import BackgroundScheduler
import threading


class Scheduler:
    """
    Singleton pattern
    """
    _instance_lock = threading.Lock()
    __instance = None

    @staticmethod
    def init_apscheduler():
        """
        Initialize the scheduled task scheduler
        :return:
        """
        with Scheduler._instance_lock:
            if Scheduler.__instance is None:
                Scheduler.__instance = BackgroundScheduler()
                Scheduler.__instance.start()
        return Scheduler.__instance


scheduler = Scheduler().init_apscheduler()
